<?php
namespace action\traits;
trait Add{
    
    function getAdd($pid){

        $model = $this->getModel();
        if($_POST){
            $info = I()->clearVar($_POST);
            $info['content'] = gav($_POST, 'content');

            if($id = $model->insert($info)){
                $this->redirect($this->urldo('index', $id));
            }
            $info = $_POST;
        } else {
            $info = [];
        }

        $this->assign('info', $info);
        $this->assign('pid', $pid);
        
        $pInfo = $model->getInfo($pid);
        $this->assign('pInfo', $pInfo);
        return $pInfo;
    }
}